#define _CRT_SECURE_NO_WARNING
#include"RBTree.h"
#include<map>

void Test1()
{
	//srand((unsigned int)time(nullptr));
	lz::RBTree<int,pair<int,int>, lz::MapKeyOfT<int,int>> t1;
	int i = 1000;
	while (i)
	{
		t1.insert(make_pair<int, int>(0+i, 1));
		i--;
	}
	//t1.insert(1);
	//t1.insert(make_pair<int,int>(1,2));
	//t1.insert(make_pair<int,int>(2,2));
	//t1.insert(make_pair<int,int>(3,2));
	//t1.insert(make_pair<int,int>(4,2));
	//t1.insert(make_pair<int, int>(2, 3));
	//t1.insert(make_pair<int, int>(4, 4));
	//t1.insert(make_pair<int, int>(8, 4));
	//t1.insert(make_pair<int, int>(6, 4));
	//t1.insert(make_pair<int, int>(7, 4));
	//t1.insert(make_pair<int, int>(12, 4));
	//lz::RBTree<int, int> t2(t1);

	//lz::RBTree<int, pair<int, int>, lz::MapKeyOfT<int,int>>::tree_const_iterator it = t1.cbegin();
	////t1[5] = pair<int,int>(19,2);
	//while (it != t1.cend())
	//{
	//	//(*it).first = 20;
	//	cout << (*it).first <<" : " << (*it).second << endl;
	//	it++;
	//}
	//cout << endl;

	//for (auto e : t1)
	//{
	//	cout << (*it).first << " : " ;
	//}
	//cout << endl;
	//t2[20] = 12;
/*	t2.deleteNode(t2.find(2));
	t2.deleteNode(t2.find(1));
	t2.deleteNode(t2.find(3));
	t2.deleteNode(t2.find(4));
	t2.deleteNode(t2.find(6));
	t2.deleteNode(t2.find(7));
	t2.deleteNode(t2.find(8));
	t2.deleteNode(t2.find(12));
	t2.deleteNode(t2.find(20))*/;
	while (i != 500)
	{		
		i++;
		t1.deleteNode(t1.find(i)._pnode);

	}
	t1.InOder();
	cout << t1.IsRBTree() << endl;
}

void Test()
{
	std::map<int, int> m;
	m.insert(make_pair<int,int>(2,1));
	m.insert(make_pair<int,int>(3,1));
	m.insert(make_pair<int,int>(4,1));
	m.insert(make_pair<int,int>(5,1));
	std::map<int, int>::iterator it = m.begin();
	while (it != m.end())
	{
		cout << (*it).first <<" : " << (*it).second << endl;
		it++;
	}
	cout << endl;
	//for (auto e : m)
	//{
	//	cout << (*it).first << " : ";
	//}
	//cout << endl;
}

int main()
{
	Test1();

	return 0;
}